import os

from langchain_community.chat_models import ChatZhipuAI
from langchain_core.prompts import ChatPromptTemplate, PromptTemplate

os.environ["ZHIPUAI_API_KEY"] = "97738d4998b8732d707daf91a2b1c56d.2y6VKEuOlidwHDpI"

model = ChatZhipuAI(
    model='glm-4',
    temperature=0
)

system_template = "Translate the following from English into {language}"
prompt_template = ChatPromptTemplate.from_messages(
    [("system", system_template), ("user", "{text}")]
)
prompt_template.invoke()

chain = prompt_template | model
print(chain.invoke({"language": "Italian", "text": "Hi!"}))
